﻿using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using HISModels.Entities;

namespace HISModels.Mapping {
    public class MedicalHistoriesMap : EntityTypeConfiguration<MedicalHistories> {
        public MedicalHistoriesMap() {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("MedicalHistories");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.EpisodeDoctorRelId).HasColumnName("EpisodeDoctorRelId");
            this.Property(t => t.RecordTime).HasColumnName("RecordTime");
            this.Property(t => t.DiseaseHistory).HasColumnName("DiseaseHistory");
            this.Property(t => t.Year).HasColumnName("Year");
            this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");

            // Relationships
            this.HasOptional(t => t.EpisodeDoctorRel)
                .WithMany(t => t.MedicalHistories)
                .HasForeignKey(d => d.EpisodeDoctorRelId);

        }
    }
}
